<template>
	<view class="CancelVoteReason">
		<!-- 立即退订原因 -->
		<u-popup :show="show" mode="center">
			<view class="popup">
				<u-cell :border="true">
					<view class="" slot="title">申请退票原因</view>
					<view class="" slot="value">
						<u-icon @click="handleCancel" name="close-circle" size="30rpx" color="rgb(144, 147, 153)">
						</u-icon>
					</view>
				</u-cell>
				<view class="popup-form">
					<u--form :model="form" ref="uForm" labelWidth="0rpx" labelAlign="right">
						<u-form-item label=" " prop="">
							<u--textarea v-model="form.value" placeholder="请输入退票原因" count height="200" maxlength="1000">
							</u--textarea>
						</u-form-item>
					</u--form>
				</view>
				<view class="popup-btn">
					<view class="cancel" @click="handleCancel">取消</view>
					<view class="submit" @click="handleSubmit">确定</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
	import {
		refundOfOrder
	} from "@/http";
	export default {
		name: "CancelVoteReason",
		data() {
			return {
				show: false,
				form: {
					value: ''
				},
				options: {},
			}
		},
		methods: {
			init(options) {
				console.log('查看内容：：：：：：',options)
				this.options = options;
				this.form.value = '';
				this.show = true;
			},
			handleCancel() {
				this.show = false;
				this.$emit('cancel');
			},
			async handleSubmit() {
				try {
					if (!this.form.value) return uni.showToast({
						title: '退票原因不能为空',
						icon: 'none'
					});
					uni.showLoading({
						title: " ",
						mask: true
					});
					let res = await refundOfOrder({
						eCodeList: this.options.eCodeList,
						orderNum: this.options.orderNum,
						refundReason: this.form.value,
						// userCard: this.options.f1,
						userName: this.options.userName,
						userPhone: this.options.userPhone
					});
					this.show = false;
					this.$emit('submit');
					uni.hideLoading();
					uni.showToast({
						title: '申请成功',
						icon: 'success'
					});
				} catch (err) {
					this.show = false;
					this.$emit('submit');
					uni.hideLoading();
				};
			}

		}
	}
</script>
<style lang="scss" scoped>
	.CancelVoteReason {
		.popup {
			width: 700rpx;

			.popup-form {
				padding: 0rpx 20rpx;
			}

			.popup-btn {
				display: flex;
				border-top: 2rpx solid #F2F2F2;

				.cancel,
				.submit {
					flex: 1;
					height: 80rpx;
					line-height: 80rpx;
					text-align: center;
				}

				.submit {
					color: #f74062;
					border-left: 2rpx solid #F2F2F2;
				}
			}
		}
	}
</style>
